package com.eascs.web.o2o.web.dao;


import java.util.List;

import javax.inject.Inject;

import org.springframework.stereotype.Repository;

import com.eascs.app.dao.JdbcSession;
import com.eascs.app.dao.PageResult;
import com.eascs.app.dao.SqlPageQuery;

@Repository
public class BiodsDao {
	@Inject
	JdbcSession jdbcSessionBiods;
	
	public <T> T insertReturnEntity(T entity) {
		int effectRow = jdbcSessionBiods.insert(entity);
		if (effectRow <= 0){
			return null;
		}
		return entity;
	}
	
	public <T> T getById(Class<T> entityClass, Object... id) {
		return jdbcSessionBiods.getById(entityClass, id);
	}
	
	public <T> PageResult<T> findDataWithPage(SqlPageQuery<T> sqlPageQuery) {
		return jdbcSessionBiods.findDataWithPage(sqlPageQuery);
	}
	
	public  String  getSql(String sql){
		return jdbcSessionBiods.getSql(sql);
	}
	
	/**
	 * 实体集合-带参数查询
	 */
	public List<Object[]> findObjectsList(String sql,Object... params){
		return jdbcSessionBiods.findObjectsList(sql,params);
	}
	
	/**
	 * 插入新数据
	 */
	public void isnertNewBusiness(String insertSql,Object... params){
		jdbcSessionBiods.execute(insertSql,params);
	}
	
	
	public <T> List<T> findEntitys(String sql, Class<T> requiredType, Object... params) {

		return jdbcSessionBiods.findEntitys(sql, requiredType, params);
	}
	
	public List<Object[]> findObjectsListForCrm(String sql,Object... params){
		return jdbcSessionBiods.findObjectsList(sql,params);		
	}
	
	public <T> T findEntity(String sql, Class<T> requiredType, Object... params) {
		return jdbcSessionBiods.findEntity(sql, requiredType, params);
	}
	
	public <T> int updateById(T entity) {
		return jdbcSessionBiods.updateById(entity);
	}
	
	
	
	public <T> int insert(T entity) {
		return jdbcSessionBiods.insert(entity);
	}
	
	
}
